<script setup>
import { ArrowRight } from '@element-plus/icons-vue'
import {computed} from 'vue'
import {useRoute} from "vue-router";
//获取路由信息
const route = useRoute();
//通过计算属性获取面包屑列表数据
const breadcrumBList= computed(() => {
  return route.matched.filter(item=>
    //过滤登录页和空路径
    item.path && item.path!=='/'&&item.meta.title
  )
})
</script>

<template>
  <div class="breadcrumb">
    <el-breadcrumb :separator-icon="ArrowRight">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item v-for="(item,index) in breadcrumBList" :key="index">{{item.meta.title}}</el-breadcrumb-item>
    </el-breadcrumb>
  </div>
</template>

<style scoped>
  .breadcrumb {
    width: 96.6%;
    height: 15px;
    background: #fff;
    padding: 15px 20px;
  }
</style>